package com.solairen.myapplication.data

import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.solairen.myapplication.net.BaseModel
import com.solairen.myapplication.net.HttpResult
import com.solairen.myapplication.net.MainRepository
import kotlinx.coroutines.launch


/**
 *
 *
 * @Date 2024/3/5 17:42
 */
class MainVM : ViewModel() {




    val loginLD = MutableLiveData<HttpResult<BaseModel<String>>>()

    val dataLD = MutableLiveData<HttpResult<BaseModel<String>>>()


//    fun login(name: String, pwd: String) {
//        viewModelScope.launch {
//            loginLD.value = MainRepository.login(name, pwd)
//        }
//    }

    fun register(name: String, pwd: String) {
        viewModelScope.launch {
            loginLD.value = MainRepository.register(name, pwd)
        }
    }

    fun getData() {
        viewModelScope.launch {
            loginLD.value = MainRepository.getData()
        }
    }
}